from django.http import JsonResponse
from django.shortcuts import HttpResponse, reverse, redirect, render


# Create your views here.


# def index_handler(request):
    # print(request.method)
    # print(request.path)
    # print(request.META['REMOTE_ADDR'])
    # print(request.META['CONTENT_TYPE'])
    # print(request.META)
    # for i in request.META.keys():
    #     print('%s = %s'%(i,request.META[i]))
    # return HttpResponse('hello python')
    # return HttpResponse(
    #     content='HttpResponse',
    #     content_type='text/plain',
    #     status=500
    # )

    # return JsonResponse(
    #     {"edu":"feiaf",
    #     "course":"放假"},
    #     json_dumps_params={'ensure_ascii':False}
    # )

def index_handler(request):
    para={
        'username':'kong',
        'password':'12345'
    }
    return render(request,'index.html',para)

def re_handler(request,num):
    return HttpResponse(num)


def user_handler(request,username):
    return HttpResponse("你好,%s"%username)

def reverse_handler(request):
    print(reverse('user:index'))
    print(reverse('user:re',args=('1234',)))
    return HttpResponse('reverse')

def redirect_handler(request):
    return redirect(reverse('user:index'))

